import { request } from 'ice';

export default {
  list: async (params) => {
    const reParams = { page: params.current, limit: params.pageSize, ...params };
    delete reParams.current;
    delete reParams.pageSize;

    return await request({
      url: '/api/sys/schedule/list',
      method: 'GET',
      params: reParams,
    });
  },
  one: async (id) => {
    return await request({
      url: `/api/sys/schedule/info/${id}`,
      method: 'GET',
    });
  },
  add: async (data) => {
    return await request({
      url: '/api/sys/schedule/save',
      method: 'POST',
      data,
    });
  },
  update: async (data) => {
    return await request({
      url: '/api/sys/schedule/update',
      method: 'POST',
      data,
    });
  },
  delete: async (ids) => {
    return await request({
      url: '/api/sys/schedule/delete',
      method: 'POST',
      data: ids,
    });
  },
  run: async (ids) => {
    return await request({
      url: '/api/sys/schedule/run',
      method: 'POST',
      data: ids,
    });
  },
  pause: async (ids) => {
    return await request({
      url: '/api/sys/schedule/pause',
      method: 'POST',
      data: ids,
    });
  },
  resume: async (ids) => {
    return await request({
      url: '/api/sys/schedule/resume',
      method: 'POST',
      data: ids,
    });
  },
  logList: async (params) => {
    const reParams = { page: params.current, limit: params.pageSize, ...params };
    delete reParams.current;
    delete reParams.pageSize;

    return await request({
      url: '/api/sys/scheduleLog/list',
      method: 'GET',
      params: reParams,
    });
  },
  logOne: async (id) => {
    return await request({
      url: `/api/sys/scheduleLog/info/${id}`,
      method: 'GET',
    });
  },
};
